package demo7;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Person implements InitializingBean, DisposableBean {
    private String name;
    private int age;
    public Person(){
        System.out.println("1:Person()的构造器执行了");
    }


    @Value("张三")
    public void setName(String name){
        System.out.println("2:初始化name属性，setName()方法执行了");
        this.name = name;
    }

    public void setAge(int age){
        System.out.println("2:初始化age属性，setAge()方法执行了");
        this.age = age;
    }

    public void afterPropertiesSet() throws Exception{
        System.out.println("3:Person对象被容器完整初始化完毕了");
    }

    public void play(){
        System.out.println("4:Person中的play()方法执行了");
    }

    public void destroy(){
        System.out.println("5:容器即将销毁，通知Person，调用destroy()方法");

    }

}
